<template>
  <view class="error-page">
    <s-empty
      v-if="errCode === 'NetworkError'"
      :icon="sheep.$url.static('/static/internet-empty.png')"
      show-action
			 :text="getLangValue('网络连接失败')"
			 :action-text="getLangValue('重新连接')"
      button-color="#ff3000"
      @clickAction="onReconnect"
    />
    <s-empty
      v-else-if="errCode === 'TemplateError'"
      :icon="sheep.$url.static('/static/internet-empty.png')"
      :text="getLangValue('未找到模板')"
      show-action
      :action-text="getLangValue('重新加载')"
      button-color="#ff3000"
      @clickAction="onReconnect"
    />
    <s-empty
      v-else-if="errCode !== ''"
      :icon="sheep.$url.static('/static/internet-empty.png')"
      :text="errMsg"
      show-action
      :action-text="getLangValue('重新加载')"
      button-color="#ff3000"
      @clickAction="onReconnect"
    />
  </view>
</template>

<script setup>
import sheep from '@/sheep'
import { onLoad } from '@dcloudio/uni-app'
import { ref } from 'vue'
import { EMSInit } from '@/sheep'
import useLang from '@/sheep/hooks/useLang.js'
	const { getLangValue } = useLang()
	
const errCode = ref('')
const errMsg = ref('')
onLoad((options) => {
  errCode.value = getLangValue(options.errCode)
  errMsg.value = getLangValue(options.errMsg)
})
// 重新连接
async function onReconnect() {
  uni.reLaunch({
    url: '/pages/index/index'
  })
  EMSInit()
}
</script>

<style lang="scss" scoped>
  .error-page {
    width: 100%;
  }
</style>
